    //
//  Xingchengdan.m
//  Untitled
//
//  Created by zou leeging on 11-1-8.
//  Copyright 2011 apple. All rights reserved.
//

#import "Xingchengdan.h"


@implementation Xingchengdan

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	
	[super loadView];
	
	UIImage *img = [UIImage imageNamed:@"loginback"];
	UIImageView *regBack = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, img.size.width, img.size.height)];
	regBack.image = img;
	[self.view addSubview:regBack];
	[regBack release];
	
	UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 60, 120, 20)];
	label.text = @"是否需要行程单";
	[label setTag:1];
	label.font = [UIFont systemFontOfSize:13];
	label.textAlignment = UITextAlignmentRight;
	label.backgroundColor = [UIColor clearColor];
	[self.view addSubview:label];
	[label release];
	
	ifNeed = [[UISegmentedControl alloc]initWithItems:nil];
	ifNeed.frame = CGRectMake(130, 60, 90, 25);
	[ifNeed insertSegmentWithTitle:@"不需要" atIndex:0 animated:YES];
	[ifNeed insertSegmentWithTitle:@"需要" atIndex:2 animated:YES];
	ifNeed.segmentedControlStyle = UISegmentedControlStyleBar;
	[ifNeed addTarget:self action:@selector(ifAddInfo) forControlEvents:UIControlEventValueChanged];
	ifNeed.selectedSegmentIndex = 0;
	
	[self.view addSubview:ifNeed];
	[ifNeed release];
	
	nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 100, 100, 25)];
	nameLabel.text = @"行程单收件人";
	nameLabel.backgroundColor = [UIColor clearColor];
	nameLabel.font = [UIFont systemFontOfSize:13];
	nameLabel.textAlignment = UITextAlignmentRight;
	nameLabel.alpha = 0;
	[self.view addSubview:nameLabel];
	[nameLabel release];
	
	nameField = [[UITextField alloc]initWithFrame:CGRectMake(110, 100, 100, 25)];
	nameField.borderStyle = UITextBorderStyleRoundedRect;
	nameField.returnKeyType = UIReturnKeyDone;
	nameField.delegate = self;
	nameField.alpha = 0;
	[self.view addSubview:nameField];
	[nameField release];
	
	//----------------
	
	zipLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 140, 100, 25)];
	zipLabel.text = @"邮政编码";
	zipLabel.backgroundColor = [UIColor clearColor];
	zipLabel.font = [UIFont systemFontOfSize:13];
	zipLabel.textAlignment = UITextAlignmentRight;
	zipLabel.alpha = 0;
	[self.view addSubview:zipLabel];
	[zipLabel release];
	
	zipField = [[UITextField alloc]initWithFrame:CGRectMake(110, 140, 100, 25)];
	zipField.borderStyle = UITextBorderStyleRoundedRect;
	zipField.returnKeyType = UIReturnKeyDone;
	zipField.delegate = self;
	zipField.alpha = 0;
	[self.view addSubview:zipField];
	[zipField release];
	//----------------
	
	addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 180, 100, 25)];
	addressLabel.text = @"收件人地址";
	addressLabel.backgroundColor = [UIColor clearColor];
	addressLabel.font = [UIFont systemFontOfSize:13];
	addressLabel.textAlignment = UITextAlignmentRight;
	addressLabel.alpha = 0;
	[self.view addSubview:addressLabel];
	[addressLabel release];
	
	addressField = [[UITextField alloc]initWithFrame:CGRectMake(110, 180, 100, 25)];
	addressField.borderStyle = UITextBorderStyleRoundedRect;
	addressField.returnKeyType = UIReturnKeyDone;
	addressField.delegate = self;
	addressField.alpha = 0;
	[self.view addSubview:addressField];
	[addressField release];
	
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
	return YES;
}
-(void)ifAddInfo {

	if (ifNeed.selectedSegmentIndex == 0)
	{
		nameLabel.alpha = 0;
		zipLabel.alpha = 0;
		addressLabel.alpha = 0;
		nameField.alpha = 0;
		zipField.alpha = 0;
		addressField.alpha = 0;
	}
	else {
		nameLabel.alpha = 1;
		zipLabel.alpha = 1;
		addressLabel.alpha = 1;
		nameField.alpha = 1;
		zipField.alpha = 1;
		addressField.alpha = 1;
	}

}

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
